<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/28 0028
 * Time: 上午 9:35
 */
namespace app\api\controller;

use app\admin\model\Askpricerecord;
use app\common\Helper;
use app\common\lib\Map;
use think\Request;

class Askprice extends Base{

    public function countPrice(){
        $count = Askpricerecord::count();
        return show(config('status.SUCCESS_STATUS'),'',$count);
    }

    public function askPriceRecord(Request $request){
        $param = $request->param();
        $address = Map::geocoder($param['askPrice']['lat'].','.$param['askPrice']['lng']);
        $Askpricerecord = new Askpricerecord();
        $Askpricerecord->id = Helper::getUUID();
        $Askpricerecord->city = $address['city'];
        $Askpricerecord->name = $param['askPrice']['name'];
        $Askpricerecord->phone = $param['askPrice']['phone'];
        $Askpricerecord->communityName = $param['askPrice']['communityName'];
        $Askpricerecord->area = $param['askPrice']['area'];
        $Askpricerecord->houseType = $param['askPrice']['houseType'];
        $Askpricerecord->style = $param['askPrice']['style'];
        $Askpricerecord->grade = $param['askPrice']['grade'];
        $Askpricerecord->createOper = $param['userId'];
        $Askpricerecord->save();
        return show(config('status.SUCCESS_STATUS'),'ok',1);
    }
}